package org.csmzxy.class2333.Stream;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class Example17 {
    public static void main(String[] args){
        List<String> members = new ArrayList<>();
        members.add("张三");
        members.add("李四");
        members.add("王五");
        members.add("赵六");
        members.add("张七");
        members.add("刘五");
        long count = members.stream().filter(m -> m.charAt(0) == '张').count();
        System.out.println("members集合中姓张的名字个数:" + count);
        List<String> newMembers = members.stream().filter(m -> !m.contains("五")).collect(Collectors.toList());
        System.out.println("members集合中名字不含'五'的名字集合:" + newMembers);
        Object[] arrMembers = members.stream().sorted().toArray();
        System.out.println("以数组形式返回按姓名升序排列后的所有元素:");
        for(Object arrMember : arrMembers){
            System.out.println(arrMember + " ");
        }
    }
}
